For this example we need to import the string library.
In [1]:
import string
Our initial example will use the uppercase letters that are in the string library.
In [2]:
print(string.ascii_uppercase)
Here we will check to see if a letter is in the string.ascii_uppercase constant.
In [3]:
if 'b' in string.ascii_uppercase:
print("Yes, the letter is in string.ascii_uppercase")
else:
print("No, the string is not in string.ascii_uppercase")
Here are some other interesting constants in the string library.
In [4]:
print(string.ascii_lowercase)
In [5]:
print(string.whitespace)
The previous example (string.whitespace) isn't easy to demonstrate because it's made up of characters like a space, a tab, and a newline character.